Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5a90f85
Solved Question 1
rishu541 Apr 21, 2023
b977dd8
Solved Question 2
rishu541 Apr 21, 2023
dbec464
Solved Question 3
rishu541 Apr 21, 2023
bcb8dfd
Solved Question 4
rishu541 Apr 21, 2023
53bd3a5
Solved Question 5
rishu541 Apr 21, 2023
8f33bc4
Solved Question 6
rishu541 Apr 21, 2023
ed96574
Solved Question 7
rishu541 Apr 21, 2023
6850fd6
Solved Question 9
rishu541 Apr 21, 2023
cd038dd
Solved Question 10
rishu541 Apr 21, 2023
d9b7fd5
Solved Question 11
rishu541 Apr 22, 2023
bc4dcff
Solved Question 12
rishu541 Apr 22, 2023
eab6cd0
Solved Question 13
rishu541 Apr 22, 2023
e6f1747
Solved Question 14
rishu541 Apr 22, 2023
4e00377
Solved Question 15
rishu541 Apr 22, 2023
f7e5be1
Solved Question 17
rishu541 Apr 22, 2023
8ff3603
Solved Question 18
rishu541 Apr 22, 2023
9d7901a
Solved Question 19
rishu541 Apr 22, 2023
926c1ae
Solved Question 20
rishu541 Apr 22, 2023
779f61d
Solved Question 21
rishu541 Apr 22, 2023
08631ab
Solved Question 22
rishu541 Apr 22, 2023
9bf1614
Solved Question 23
rishu541 Apr 22, 2023
46cfb1b
Solved Question 24
rishu541 Apr 22, 2023
646106b
Solved Question 25
rishu541 Apr 22, 2023
b001453
Solved Question 26
rishu541 Apr 22, 2023
9c417b9
Solved Question 27
rishu541 Apr 22, 2023
8f78705
Solved Question 28
rishu541 Apr 22, 2023
e68c962
Solved Question 29
rishu541 Apr 22, 2023
c815e10
Solved Question 30
rishu541 Apr 22, 2023
e694e0a
Solved Question 31
rishu541 Apr 22, 2023
6c6f25a
Solved Question 32
rishu541 Apr 22, 2023
1723134
Solved Question 34
rishu541 Apr 23, 2023
fe0c546
Solved Question 33
rishu541 Apr 23, 2023
9a9b8e2
Improved Question 19
rishu541 Apr 23, 2023
edf50f0
Improved Question 01
rishu541 Apr 23, 2023
157c913
Improved Question 28
rishu541 Apr 23, 2023
853704c
Solved Question 8
rishu541 Apr 23, 2023
133bb19
Updated Question 1
rishu541 Apr 23, 2023
1e4fefc
Removed unsolved
rishu541 Apr 24, 2023
2013cca
Added Approach along with missing question
rishu541 May 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Q1/approch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Number of Opeartions : 3

1. modify-overwrite-beta
2. shift
3. modify-overwrite-beta

## Explaination

1. I have combined `firstName` and `lastName` to form `fullName` and converted `address` to string using concat function.
2. Calculated the `price` as per quantity by caculating inverse and `divide` function. and converted the price to double.
3. created a array of total price for each object of `orders` and sum the total price using `doubleSum` function.
59 changes: 59 additions & 0 deletions Q1/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"orders": [
{
"orderId": 1,
"orderDate": "2022-02-20T12:34:56Z",
"customer": {
"customerId": 1,
"firstName": "John",
"lastName": "Doe",
"email": "johndoe@example.com",
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
}
},
"items": [
{
"itemId": 1,
"name": "Product A",
"quantity": 2,
"price": 10.0
},
{
"itemId": 2,
"name": "Product B",
"quantity": 1,
"price": 20.0
}
]
},
{
"orderId": 2,
"orderDate": "2022-02-21T09:12:34Z",
"customer": {
"customerId": 2,
"firstName": "Jane",
"lastName": "Smith",
"email": "janesmith@example.com",
"address": {
"street": "456 Oak St",
"city": "Somewhere",
"state": "NY",
"zip": "67890"
}
},
"items": [
{
"itemId": 3,
"name": "Product C",
"quantity": 3,
"price": 15.0
}
]
}
]
}

48 changes: 48 additions & 0 deletions Q1/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"orders": [
{
"orderId": 1,
"orderDate": "2022-02-20T12:34:56Z",
"customer": {
"customerId": 1,
"fullName": "John Doe",
"email": "johndoe@example.com",
"address": "123 Main St, Anytown, CA 12345"
},
"items": [
{
"itemId": 1,
"name": "Product A",
"quantity": 2,
"price": 10.0
},
{
"itemId": 2,
"name": "Product B",
"quantity": 1,
"price": 20.0
}
],
"total": 40.0
},
{
"orderId": 2,
"orderDate": "2022-02-21T09:12:34Z",
"customer": {
"customerId": 2,
"fullName": "Jane Smith",
"email": "janesmith@example.com",
"address": "456 Oak St, Somewhere, NY 67890"
},
"items": [
{
"itemId": 3,
"name": "Product C",
"quantity": 3,
"price": 15.0
}
],
"total": 45.0
}
]
}
76 changes: 76 additions & 0 deletions Q1/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[
{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"customer": {
"fullName": "=concat(@(1,firstName),' ',@(1,lastName))",
"address": "=concat(@(0,street),', ',@(0,city),', ',@(0,state),' ',@(0,zip))"
},
"items": {
"*": {
"inverse": "=divide(1, @(1,quantity))",
"intPrice": "=divide(@(1,price), @(1,quantityInverse))",
"price": "=toDouble"
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"orders": {
"*": {
"items": {
"*": {
"totalQuantity": "&4.[#4].total[]"
}
},
"@": "&2.[&]"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"total": "=doubleSum(@(1,total))"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"orders": {
"*": {
"total": "=doubleSum(@(1,total))"
}
}
}
},
{
"operation": "remove",
"spec": {
"orders": {
"*": {
"customer": {
"firstName": "",
"lastName": ""
},
"items": {
"*": {
"inverse": "",
"intPrice": ""
}
}
}
}
}
}
]
9 changes: 9 additions & 0 deletions Q10/approach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Number of Opeartion : 2

1. modify-overwrite-beta : string transform
2. remove : remove unwanted keys

## Explaintaion

1. Used `split` function to split the `name` by blank space into `temp1` field and created `first_name` from 0th and `last_name` from 1st index of `temp1` field using `firstElement` and `lastElement` function respectively.
2. Removed the `name` and `temp1` entry from object using `remove` operation by setting the value of both to `""`.
20 changes: 20 additions & 0 deletions Q10/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "John Smith",
"age": 35,
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
"phone_numbers": [
{
"type": "home",
"number": "555-1234"
},
{
"type": "work",
"number": "555-5678"
}
]
}
22 changes: 22 additions & 0 deletions Q10/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"age": 35,
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
"phone_numbers": [
{
"type": "home",
"number": "555-1234"
},
{
"type": "work",
"number": "555-5678"
}
],
"first_name": "John",
"last_name": "Smith",
"phone_number_count": 2
}
18 changes: 18 additions & 0 deletions Q10/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"operation": "modify-overwrite-beta",
"spec": {
"temp1": "=split(' ',@(1,name))",
"first_name": "=firstElement(@(1,temp1))",
"last_name": "=lastElement(@(1,temp1))",
"phone_number_count": "=size(@(1,phone_numbers))"
}
},
{
"operation": "remove",
"spec": {
"temp1": "",
"name": ""
}
}
]
7 changes: 7 additions & 0 deletions Q11/approach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Number of Opeartion : 1

1. shift : changing key names

## Explaintaion

1.Changed the key names in the items array by looping over the array and setting the `name` and `value` key name to `itemName` and `itemValue` respectively using `shift` operation.
12 changes: 12 additions & 0 deletions Q11/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"items": [
{
"name": "item1",
"value": 10
},
{
"name": "item2",
"value": 20
}
]
}
12 changes: 12 additions & 0 deletions Q11/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"items": [
{
"itemName": "item1",
"itemValue": 10
},
{
"itemName": "item2",
"itemValue": 20
}
]
}
13 changes: 13 additions & 0 deletions Q11/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"operation": "shift",
"spec": {
"items": {
"*": {
"n*": "items[#2].itemName",
"v*": "items[#2].itemValue"
}
}
}
}
]
9 changes: 9 additions & 0 deletions Q12/approach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Number of Opeartion : 2

1. modify-overwrite-beta : string transform
2. shift : upwrap object.

## Explaintaion

1. Changed all the case of all keys to uppercase using `shift` opeartion.
2. Converted the hobby array to array of objects by looing over the array and changing the name of each key to `Name` using `@` wildcard and `shift` operation.
22 changes: 22 additions & 0 deletions Q12/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"employee": {
"firstName": "John",
"lastName": "Doe",
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": "12345"
},
"phones": [
{
"type": "home",
"number": "555-555-1234"
},
{
"type": "work",
"number": "555-555-5678"
}
]
}
}
14 changes: 14 additions & 0 deletions Q12/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "John Doe",
"address": "123 Main St, Anytown, CA 12345",
"phones": [
{
"type": "home",
"number": "555-555-1234"
},
{
"type": "work",
"number": "555-555-5678"
}
]
}
21 changes: 21 additions & 0 deletions Q12/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"operation": "modify-overwrite-beta",
"spec": {
"employee": {
"name": "=concat(@(1,firstName),' ',@(1,lastName))",
"address": "=concat(@(0,street),', ',@(0,city),', ',@(0,state),' ',@(0,zip))"
}
}
},
{
"operation": "shift",
"spec": {
"employee": {
"name": "&",
"address": "&",
"phones": "&"
}
}
}
]
Loading